﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Hard_4_FindMedianSortedArrays
{
    class MainProject
    {
        static void Main(string[] args)
        {
            Console.WriteLine(FindMedianSortedArrays(new int[] {1,2 },new int[] {3,4 }));
            //Console.WriteLine(IsPalindrome(1000021));
            Console.ReadKey();
        }

        public static double FindMedianSortedArrays(int[] nums1, int[] nums2)
        {
            List<int> list = new List<int>();
            list.AddRange(nums1);
            list.AddRange(nums2);
            list.Sort();

            double res = 0;

            if (list.Count % 2 == 0)
            {
                int rightIndex = (list.Count) / 2;
                int leftIndex = rightIndex - 1;
                res = (double)(list[rightIndex] + list[leftIndex]) / 2;
            }
            else
            {
                res = list[list.Count / 2];
            }
            return res;
        }
    }
}
